package com.example.administrator.myapplication;

import android.app.Activity;
import android.os.Bundle;
import android.widget.ExpandableListView;

import com.example.administrator.myapplication.adapter.RankListAdapter;
import com.example.administrator.myapplication.bean.ScoreBean;
import com.example.administrator.myapplication.biz.ScoreBiz;


import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class RankActivity extends Activity {
    private static final String[] GROUP_NAME = new String[]{"\t\t简单的","\t\t一般的","\t\t困难的"};
    private ExpandableListView mListView;
    private Map<String,List<ScoreBean>> mScoreMap;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_rank);
        mListView = (ExpandableListView) findViewById(R.id.rank_list);
        //查询数据
        ScoreBiz biz = new ScoreBiz(this);
        mScoreMap = new HashMap<>();
        for (int i = 0; i < GROUP_NAME.length ; i++) {
            List<ScoreBean> list = biz.query(i+3);
            mScoreMap.put(GROUP_NAME[i],list);
        }
        //关联适配器
        RankListAdapter adapter = new RankListAdapter(this,mScoreMap,GROUP_NAME);
        mListView.setAdapter(adapter);
    }
}
